<?php
/*
$hb = imagecreatetruecolor(400, 400);//创建画布
$zise = imagecolorallocate($hb, 198, 145, 223);//设置颜色
$blue = imagecolorallocate($hb, 122, 232, 212);
$red = imagecolorallocate($hb, 255, 0, 0);
$white = imagecolorallocate($hb, 255, 255, 255);
$arr = [200,100,100,200,300,200];

imagefill($hb, 0, 0, $blue);//绘制背景色
imageline($hb, 20, 100, 20, 300, $zise);//画线
imagestring($hb, 5, 100, 50, 'Welcome to my world', $zise);//字符串
imagestringup($hb, 5, 50, 50, 'mmp', $red);
imagefilledpolygon($hb, $arr, count($arr)/2, $red);//画填充多边形  只要线条就去掉filled
imagesetpixel($hb, 200, 150, $white);//画点
imagefilledrectangle($hb, 50, 200, 100, 350, $zise);//矩形
imageellipse($hb, 200, 260, 200, 100, $zise);//椭圆
imagearc($hb, 210, 310, 100, 100, 30, 60, $red);//画狐
 */
$a = 4;
$width = $a*100;
$hb    = imagecreatetruecolor($width, 100);
$white = imagecolorallocate($hb, 255, 255, 255);
imagefill($hb, 0, 0, $white);

for ($i = 0; $i < 10; $i++) {
    $randcolor = imagecolorallocate($hb, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
    imageline($hb, mt_rand(0, 100*$a), mt_rand(0, 100), mt_rand(0, 100*$a), mt_rand(0, 100), $randcolor);
}

for ($i = 0; $i < 1000; $i++) {
    $randcolor = imagecolorallocate($hb, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
    imagesetpixel($hb, rand(0, 100*$a), rand(0, 100), $randcolor);
}
for ($i=0; $i <$a ; $i++) { 
	$randcolor = imagecolorallocate($hb, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
	$str = 'qwertyuiopasdfgghjklzxcvbbnm0123456789QWWERRTYUIOPASADFGHJKLZXCVBNM';
	$len = strlen($str);
	$index= mt_rand(0,$len-1);
	$randfont = $str[$index];
imagettftext($hb, 50, mt_rand(-20,20), 20+100*$i, 80, $randcolor, 'simkai.ttf', $randfont);
}

header('Content-type:image/png');
imagepng($hb); //以png格式将图像输出
imagedestroy($hb);
